/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


/**
 *
 * @author Andrés Felipe
 */
@Entity
@Table(name = "\"javeriana.sc.cc\".\"t_supplierXpyme\"")
@XmlRootElement
@NamedQuery(name = "SupplierXpyme.findByPyme", query = "SELECT s.supplier FROM SupplierXpyme s WHERE s.pyme.identification = :identification")
public class SupplierXpyme implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @EmbeddedId
    protected SupplierXpymePK supplierXpymePK;
    @ManyToMany(mappedBy = "supplierXpymeList")
    private List<Material> materialList;
    @JoinColumn(name = "supplierindentification", referencedColumnName = "identification", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Supplier supplier;
    @JoinColumn(name = "pymeidentification", referencedColumnName = "identification", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Pyme pyme;
    

    public SupplierXpyme() {
    }

    public SupplierXpyme(int supplierindentification, int pymeidentification) {
        this.supplierXpymePK = new SupplierXpymePK(supplierindentification, pymeidentification);
    }

    public SupplierXpymePK getSupplierXpymePK() {
        return supplierXpymePK;
    }

    public void setSupplierXpymePK(SupplierXpymePK supplierXpymePK) {
        this.supplierXpymePK = supplierXpymePK;
    }

    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Pyme getPyme() {
        return pyme;
    }

    public void setProduct(Pyme pyme) {
        this.pyme = pyme;
    }

    @XmlTransient
    public List<Material> getMaterialList() {
        return materialList;
    }

    public void setMaterialList(List<Material> materialList) {
        this.materialList = materialList;
    }

    

    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (supplierXpymePK != null ? supplierXpymePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof SupplierXpyme)) {
            return false;
        }
        SupplierXpyme other = (SupplierXpyme) object;
        if ((this.supplierXpymePK == null && other.supplierXpymePK != null) || (this.supplierXpymePK != null && !this.supplierXpymePK.equals(other.supplierXpymePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.SupplierXproduct[ supplierXproductPK=" + supplierXpymePK + " ]";
    }
    
}
